function register() {
	var name = $("#name_input").val();
	var gender = $('input[name=genderRadio]:checked').val();
	var dateOfBirth = $("#dateOfBirth_input").val();
	var address = $("#address_input").val();
	var occupation = $("#occupation_input").val();
	var civilStatus = $("input[name=civilStatusRadio]:checked").val();
	var physician = $("#physician_input").val();
	var clinicalStatus = $("input[name=clinicalStatusRadio]:checked").val();
	var medicalHistory = $("#medicalHistory_input").val();

	$.post("RegisterPatient", {
		request : "register-patient",
		name : name,
		gender : gender,
		dateOfBirth : dateOfBirth,
		address : address,
		occupation : occupation,
		civilStatus : civilStatus,
		physician : physician,
		clinicalStatus : clinicalStatus,
		medicalHistory : medicalHistory
	}, function(data) {
		registerPatientResponse(data);
	});
}

function registerPatientResponse(data) {
	$("#patientList_table tbody").append(
			buildRow(data.id, data.name, data.physician, data.gender));

	$('#register_new_patient_modal').modal('hide');
}

function buildRow(id, name, physician, gender) {
	return '<tr>' + '<td>' + id + '</td>' + '<td><a href=' + id + '>' + name
			+ '</a></td>' + '<td>' + gender + '</td>' + '<td>' + physician
			+ '</td>' + '</tr>';
}

function clearForm() {
	$("#name_input").val("");
	$('input[name=genderRadio]:checked').prop('checked', false);
	$("#dateOfBirth_input").val("01/01/2012");
	$("#address_input").val("");
	$("#occupation_input").val("");
	$("input[name=civilStatusRadio]:checked").prop('checked', false);
	$("#physician_input").val("");
	$("input[name=clinicalStatusRadio]:checked").prop('checked', false);
	$("#medicalHistory_input").val("");
}